<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: product_reviews_info.php 201 2013-09-22 07:58:51Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 201 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-09-22 07:58:51 +0000 (Sun, 22 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

include ('includes/application_top.php');

$smarty = new Smarty;

require (DIR_FS_CATALOG.'templates/'.CURRENT_TEMPLATE.'/source/boxes.php');
require_once (DIR_FS_INC.'inc.break_string.php');
require_once (DIR_FS_INC.'inc.date_long.php');

$get_params = get_all_get_params(array ('reviews_id'));
$get_params = substr($get_params, 0, -1);

$reviews = $db->db_query("SELECT 
								rd.reviews_text, 
								r.reviews_rating, 
								r.reviews_id, 
								r.products_id, 
								r.customers_name, 
								r.date_added, 
								r.last_modified, 
								r.reviews_read, 
								p.products_id, 
								pd.products_name, 
								p.products_image 
							FROM 
								".TABLE_REVIEWS." r 
								LEFT JOIN 
									".TABLE_PRODUCTS." p 
								ON 
									(r.products_id = p.products_id) 
								LEFT JOIN 
									".TABLE_PRODUCTS_DESCRIPTION." pd 
								ON 
									(p.products_id = pd.products_id 
							AND 
								pd.language_id = '".(int)$_SESSION['languages_id']."'), 
								".TABLE_REVIEWS_DESCRIPTION." rd 
							WHERE 
								r.reviews_id = '".(int)$_GET['reviews_id']."' 
							AND 
								r.reviews_id = rd.reviews_id 
							AND 
								p.products_status = '1'");

if(!$reviews->_numOfRows)
	redirect(href_link(FILENAME_REVIEWS));


$breadcrumb->add(NAVBAR_TITLE_PRODUCT_REVIEWS, href_link(FILENAME_PRODUCT_REVIEWS, $get_params));

$db->db_query("UPDATE ".TABLE_REVIEWS." SET reviews_read = reviews_read+1 WHERE reviews_id = '".$reviews->fields['reviews_id']."'");

$reviews_text = break_string(htmlspecialchars($reviews->fields['reviews_text']), 60, '-<br />');

require(DIR_WS_INCLUDES.'header.php');

$smarty->assign('PRODUCTS_NAME', $reviews->fields['products_name']);
$smarty->assign('AUTHOR', $reviews->fields['customers_name']);
$smarty->assign('DATE', date_long($reviews->fields['date_added']));
$smarty->assign('REVIEWS_TEXT', nl2br($reviews_text));
$smarty->assign('RATING', image('templates/'.CURRENT_TEMPLATE.'/img/stars_'.$reviews->fields['reviews_rating'].'.png', sprintf(TEXT_OF_5_STARS, $reviews->fields['reviews_rating'])));
$smarty->assign('PRODUCTS_LINK', href_link(FILENAME_PRODUCT_INFO, product_link($reviews->fields['products_id'], $reviews->fields['products_name'])));
$smarty->assign('BUTTON_BACK', '<a href="'.href_link(FILENAME_PRODUCT_REVIEWS, 'products_id='.$reviews->fields['products_id']).'">'.image_button('button_back.gif', 'alle Bewertungen dieses Produkts').'</a>');
$smarty->assign('PRODUCTS_BUTTON_DETAILS', '<a href="'.href_link(FILENAME_PRODUCT_INFO, 'products_id='.$reviews->fields['products_id']).'">'.image_button('button_details.gif', 'Details').'</a>');
$smarty->assign('IMAGE', image(DIR_WS_THUMBNAIL_IMAGES.$reviews->fields['products_image'], $reviews->fields['products_name']));

$smarty->assign('language', $_SESSION['language']);

if(!CacheCheck()) {
	$smarty->caching = false;
	$main_content = $smarty->fetch(CURRENT_TEMPLATE.'/module/product_reviews_info.html');
} else {
	$smarty->caching = true;
	$smarty->cache_lifetime = CACHE_LIFETIME;
	$smarty->cache_modified_check = CACHE_CHECK;
	$cache_id = $_SESSION['language'].$reviews->fields['reviews_id'];
	$main_content = $smarty->fetch(CURRENT_TEMPLATE.'/module/product_reviews_info.html', $cache_id);
}

$smarty->assign('language', $_SESSION['language']);
$smarty->assign('main_content', $main_content);
$smarty->caching = false;
if (!defined('RM'))
	$smarty->loadFilter('output', 'note');
$smarty->loadFilter('output','trimwhitespace');
$smarty->display(CURRENT_TEMPLATE.'/index.html');
include ('includes/application_bottom.php');
?>